import sys

from PySide6.QtWidgets import QApplication, QMainWindow, QTextEdit

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.editor = QTextEdit()
        print("file:", __file__)

        if __file__ in sys.argv:
            sys.argv.remove(__file__)

        if sys.argv:
            filename = sys.argv[1]
            self.open_file(filename)

        self.setCentralWidget(self.editor)
        self.setWindowTitle("Text viewer")

    def open_file(self, filename):
        with open(filename, "r") as f:
            text = f.read()

        self.editor.setText(text)

app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()